package com.wanmait.shoppingsys.util;

import java.util.ArrayList;
import java.util.List;

import com.wanmait.shoppingsys.vo.Specialty;

public class Favorite {
	
	private ArrayList<Specialty> specialtyss = new ArrayList<Specialty>();
	
	
	public void remove(Integer id) {     //删除商品
		for(Specialty b:specialtyss) {
			if(b.getId().equals(id)) {
				specialtyss.remove(b);
				break;
			}
		}
	}
	
	 public void addCommoditys (Specialty specialty)    //往收藏夹添加商品
	  {
		  boolean find = false;
		  for(Specialty b:specialtyss)
		  {
			  if(b.getId().equals(specialty.getId()))
			  {
				 b.setCount(b.getCount()+specialty.getCount()); 
				 find = true;
				 break;
			  }
		  }
		  if(!find)
		  {
			  specialtyss.add(specialty) ; 
		  }
	  }
	  public List<Specialty> getSpecialtys()
	  {
		  return  specialtyss;
	  }
	
}
